import React from 'react';
import {
  Route,
  Switch,
  HashRouter as Router,
  Redirect
} from 'react-router-dom';
import './component/reset.css'

import Auth from './component/Auth';
import Home from './component/Home';
import Msg from './component/Root/Home/Msg';  //消息
import MsgDetail from './component/Root/Home/MsgDetail';  //消息详情
import Search from './component/Root/Home/Search';  //搜索
import SearchResult from './component/Root/Home/SearchResult';  //搜索结果
import Classify from './component/Root/Home/Classify';  //更多分类
import SquareDetail from './component/Root/Square/Detail';  //广场详情
import Release from './component/Root/Square/Release';  //广场发布
import SendComment from './component/Root/Square/SendComment';  //广场评论
import SqList from './component/Root/Square/List';  //排行榜
import Activity from './component/Root/Home/Activity';  //抖音培训、活动报名、公益活动
import Service from './component/Root/Home/Service';  //租借服务、创作服务
import ServiceDetail from './component/Root/Home/ServiceDetail';  //租借服务详情、创作服务详情
import LearnDetail from './component/Root/Learn/Detail';  //课程详情
import Order from './component/Root/Learn/Order';  //订单结算
import Video from './component/Root/Learn/Video';  //播放视频
import Audio from './component/Root/Learn/Audio';  //播放音频
import Pay from './component/Root/Learn/Pay';  //支付
import SignUpDetail from './component/Root/SignUp/Detail';  //报名详情
import Moment from './component/Root/SignUp/Moment';  //精彩瞬间详情
import Set from './component/Root/User/Set';  //设置
import SetName from './component/Root/User/SetName';  //修改昵称
import Editpwd from './component/Root/User/Editpwd';  //修改登录密码
import Withdrawal from './component/Root/User/Withdrawal';  //提现
import Paytype from './component/Root/User/Paytype';  //提现方式
import BindPaytype from './component/Root/User/BindPaytype';  //添加提现方式
import OrderList from './component/Root/User/OrderList';  //我的订单
import OrderDetail from './component/Root/User/OrderDetail';  //订单详情
import Team from './component/Root/User/Team';  //我的团队
import ActivityList from './component/Root/User/Activity';  //我的活动
import ActivityDetail from './component/Root/User/ActivityDetail';  //活动详情
import Medal from './component/Root/User/Medal';  //学习勋章
import MedalDetail from './component/Root/User/MedalDetail';  //学习勋章详情
import Vip from './component/Root/User/Vip';  //年费会员
import Share from './component/Root/User/Share';  //邀请好友
import Drainage from './component/Root/Home/Drainage';  //引流页

import PayVip from './component/Root/User/Pay';  //购买年费会员
import CrystalExchange from './component/Root/User/CrystalExchange';  //水晶兑换
import JoinAGrp from './component/Root/User/joinAGrp';  //拼团

import Ajax from './class/Ajax';
global.Ajax=new Ajax();

export default class App extends React.Component {
	constructor(props){
		super(props)
		this.state={
			path: ''
		}
	}
	componentDidMount(){
		var path;
		if(localStorage.getItem('token')){
			path='/home/home/index'
		}else{
			path='/login/login/login'
		}
		this.setState({
			path: path
		})
	}
	render(){
		return(
			<Router>
				<Switch>
					<Route path="/login" component={Auth} />
					<Route path="/home" component={Home} />
					<Route path='/page/home/home/search' component={Search} />
					<Route path='/page/home/home/searchresult/:name' component={SearchResult} />
					<Route path='/page/home/home/msg' component={Msg} />
					<Route path='/page/home/home/msgdetail' component={MsgDetail} />
					<Route path='/page/home/home/classify/:type' component={Classify} />
					<Route path='/page/home/home/activity/:name/:type' component={Activity} />
					<Route path='/page/home/home/service/:name/:id' component={Service} />
					<Route path='/page/home/home/servicedetail/:id' component={ServiceDetail} />
					<Route path='/page/home/square/squaredetail/:id' component={SquareDetail} />
					<Route path='/page/home/square/release/:type' component={Release} />
					<Route path='/page/home/square/sendcomment/:id' component={SendComment} />
					<Route path='/page/home/square/sqlist' component={SqList} />
					<Route path='/page/home/learn/learndetail/:id' component={LearnDetail} />
					<Route path='/page/home/learn/Order/:id' component={Order} />
					<Route path='/page/home/learn/video/:id/:type' component={Video} />
					<Route path='/page/home/learn/audio/:id/:type' component={Audio} />
					<Route path='/page/home/learn/pay/:id/:status' component={Pay} />
					<Route path='/page/home/signup/detail/:id' component={SignUpDetail} />
					<Route path='/page/home/signup/moment/:id' component={Moment} />
					<Route path='/page/home/user/set' component={Set} />
					<Route path='/page/home/user/setname/:nickname' component={SetName} />
					<Route path='/page/home/user/editpwd' component={Editpwd} />
					<Route path='/page/home/user/withdrawal/:bl' component={Withdrawal} />
					<Route path='/page/home/user/paytype/:id' component={Paytype} />
					<Route path='/page/home/user/bindpaytype/:type' component={BindPaytype} />
					<Route path='/page/home/user/orderlist' component={OrderList} />
					<Route path='/page/home/user/orderdetail/:id' component={OrderDetail} />
					<Route path='/page/home/user/team' component={Team} />
					<Route path='/page/home/user/activity' component={ActivityList} />
					<Route path='/page/home/user/activitydetail/:id' component={ActivityDetail} />
					<Route path='/page/home/user/medal' component={Medal} />
					<Route path='/page/home/user/medaldetail/:id' component={MedalDetail} />
					<Route path='/page/home/user/vip' component={Vip} />
					<Route path='/page/home/user/share' component={Share} />
					<Route path='/page/home/user/drainage' component={Drainage} />
					<Route path='/page/home/user/payvip' component={PayVip} />
					{/* 水晶分享 */}
					<Route path='/page/home/user/crystalExchange' component={CrystalExchange} />
					{/* 拼团 */}
					<Route path='/page/home/user/joinAGrp' component={JoinAGrp} />

					<Redirect to={this.state.path} />
				</Switch>
			</Router>
		)
	}
}
